#include <string>
#include <iostream>

#include "SocketConnector.h"

int main()
{
  char choice;
  std::string message;
  std::string value;

  InetAddress addr1("127.0.0.1", "15000");
  InetAddress addr2("127.0.0.1", "15001");
  InetAddress addr3("127.0.0.1", "15002");

  SocketConnector alarm(addr1);
  SocketConnector log(addr2);
  SocketConnector patient(addr3);

  SocketStream alarmConn;
  SocketStream logConn;
  SocketStream patientConn;

  alarm.getStream(alarmConn);
  log.getStream(logConn);
  patient.getStream(patientConn);

  while (true)
    {      
      std::cout << "Choose event type!\n" << "  1 - AlarmEvent\n" << "  2 - LogEvent\n" << "  3 - PatientEvent\n";
      std::cin >> choice;
      std::cin.get();

      switch(choice)
	{
	case '1':
	  {
	    std::cout << "Enter your alarm message: ";
	    std::getline(std::cin, message);
	    std::cout << ".. with prio [1-10]: ";
	    std::getline(std::cin, value);

	    message.append("\n");
	    message.append(value);

	    alarmConn.send(message);
	    break;
	  }
	case '2':
	  {
	    std::cout << "Enter your log message: ";
	    std::getline(std::cin, message);

	    logConn.send(message);
	    break;
	  }
	case '3':
	  {
	    std::cout << "Enter your patient type: ";
	    std::getline(std::cin, message);
	    std::cout << ".. with value: ";
	    std::getline(std::cin, value);	    

	    message.append("\n");
	    message.append(value);

	    patientConn.send(message);
	    break;
	  }
	default:
	  std::cout << "Invalid choice\n";
	}
    }
  
}
